// 物业公司
import CompanySelect from '@/views/PropertyCompany/components/CompanySelect.vue'
// 项目
import CommunitySelect from '@/views/PropertyCompany/components/CommunitySelect.vue'
import OrganizationSelect from '@/components/Organization/OrganizationSelect.vue'
//选择开庭法院
import CourtSelect from '@/views/Court/components/CourtSelect.vue'
import { useRoute } from 'vue-router'

//根据传入的options，动态生成filters
export const useCommonFilter = function (options) {
  const route = useRoute()

  const filters = [
    {
      key: 'company_id',
      type: 'custom',
      props: { placeholder: '请选择物业公司' },
      render: CompanySelect,
      value: Number(route.query.company_id) || null,
    },
    {
      key: 'community_id',
      type: 'custom',
      props: { placeholder: '请选择项目' },
      dynamicProps: (params) => {
        return {
          companyId: params.company_id,
        }
      },
      render: CommunitySelect,
      value: Number(route.query.community_id) || null,
    },
    {
      key: 'department_id',
      type: 'custom',
      props: { placeholder: '请选择部门', type: 'department' },
      render: OrganizationSelect
    },
    {
      key: 'open_court_user_id',
      type: 'custom',
      props: { placeholder: '请选择开庭律师', type: 'user' },
      render: OrganizationSelect
    },
    {
      key: 'user_id',
      type: 'custom',
      props: { placeholder: '请选择跟案律师', type: 'user' },
      render: OrganizationSelect
    },
    {
      key: 'court_id',
      type: 'custom',
      props: { placeholder: '请选择开庭法院' },
      render: CourtSelect,
    },
  ].filter((v) => options.includes(v.key))
  return {
    filters,
  }
}
